using System;
using System.Reflection;
using System.Text;

namespace Kopernikus.Parsing.GenericActions
{
    public class InvalidSemanticActionException : InvalidGenericActionException
    {
        public InvalidSemanticActionException(MethodInfo methodInfo, Type expectedReturnType)
            : base(FormatMessage(methodInfo, expectedReturnType))
        {
        }

        private static string FormatMessage(MethodInfo methodInfo, Type expectedReturnType)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("The method {0} has a bad signature.", methodInfo);
            sb.AppendLine();
            sb.AppendFormat("Change signature to {0} {1}({0}[]).", expectedReturnType.Name, methodInfo.Name);
            return sb.ToString();
        }
    }
}